home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8009 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.3 KB  |  59 lines

  1. Path: news.intersurf.net!usenet
  2. From: "David C. Branton" <dbranton@intersurf.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: strcpy problem
  5. Date: Sat, 17 Feb 1996 10:21:06 -0800
  6. Organization: McKinley High School
  7. Message-ID: <31261C92.3DEE@intersurf.com>
  8. NNTP-Posting-Host: ts1-29.intersurf.com
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0 (Win16; I)
  13.  
  14. strcpy does not seem to work in this case. Can anyone explain why?
  15.  
  16. Here is the setup:
  17.  
  18. class league
  19. { protected:
  20.  ...
  21.   struct franchise
  22.   {...
  23.     struct person
  24.     {  char name [25];
  25.        ...
  26.     }
  27.   }team [12];
  28.    
  29.   public:
  30.   void draftplayer ();
  31.   ...
  32. }; 
  33.  
  34. void league::draftplayer()
  35. {
  36.   char playername[25];
  37.   ...
  38.  
  39.   // playername is given a value; tracing confirms that it has a value
  40.  
  41.   strcpy(team[draftpick-1].player[round-1].name, playername);
  42.  
  43. ...
  44.  
  45. }
  46.  
  47. The line strcpy... does not copy the string. When code is traced, there 
  48. is a proper value for playername but nothing gets copied into the nested 
  49. structure.  All variable have been properly declared and have values at 
  50. this point.
  51.  
  52. Any ideas as to why strcpy does not work in this case?
  53.  
  54. Thanks in advance.
  55. -- 
  56. David Branton              dbranton@intersurf.com
  57. McKinley High School       
  58. Computer Science
  59.